﻿#############################################
# Title: Download-MySPLanguagePacks.ps1		#
# Author: Wahid Saleemi						#
# Twitter: @wahidsaleemi					#
# Reference: http://www.wahidsaleemi.com	#
#############################################

# Description: Retrieves the selected SharePoint language packs from Microsoft to store locally.
# Culture short codes from http://technet.microsoft.com/en-us/library/system.globalization.cultureinfo(VS.85).aspx

# Define our variables
$InputFile = "languages.xml"

# No need to edit below this line
[xml]$xmlinput = (Get-Content $InputFile)
Import-Module BitsTransfer


# ===================================================================================
# Func: ShouldIDownload
# Desc: Returns TRUE if the item whose configuration node is passed in should be
#       downloaded on this machine.
# ===================================================================================
Function ShouldIDownload([System.Xml.XmlNode] $node)
{
	$v = ($node.GetAttribute("Download"))
	If ($v -eq $true) { Return $true; }
	$v = " " + $v + " ";
	If ($v.IndexOf(" " + $env:ComputerName + " ") -ge 0) { Return $true; }
	Return $false;
}
# End Function

# ====================================================================================
# Func: WriteLine
# Desc: Writes a nice line of dashes across the screen
# ====================================================================================
Function WriteLine
{
	Write-Host -ForegroundColor White "--------------------------------------------------------------"
}
# End Function

# ===================================================================================
# Func: Pause
# Desc: Wait for user to press a key - normally used after an error has occured
# ===================================================================================
Function Pause
{
	#From http://www.microsoft.com/technet/scriptcenter/resources/pstips/jan08/pstip0118.mspx
	Write-Host "Press any key to exit..."
	$null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
# End Function

# ===================================================================================
# Func: Start-LPDownload
# Desc: Starts the download of the language pack.
# ===================================================================================
Function Start-LPDownload([string]$culture)
{
	WriteLine
	Write-Host "Starting Download... $culture"
	## Get the file name based on the part of the URL after the last slash and replace the end with culture short code.
	$newname = "_" + "$culture" + ".exe"
	$DestFileName = $Url.Split('/')[-1] -replace ".exe",$newname
	Try
	{
	## Check if destination file already exists
	If (!(Test-Path "$DestFolder\$DestFileName"))
		{
			## Begin download
			Start-BitsTransfer -Source $Url -Destination $DestFolder\$DestFileName -DisplayName "Downloading `'$DestFileName`' to $DestFolder" -Priority High -Description "From $Url..." -ErrorVariable err
			If ($err) {Throw ""}
		}
	Else
		{
			Write-Host " - File $DestFileName already exists, skipping..."
		}
		}
	Catch
		{
			Write-Warning " - An error occurred downloading `'$DestFileName`'"
			break
		}
}
# End Function

# ===================================================================================
# Func: Download-Arabic
# Desc: ar-SA
# ===================================================================================
# Region Download Arabic
Function Download-Arabic([xml]$xmlinput)
{
	$culture = "ar-SA" #Used to rename filename
	$Url = "http://download.microsoft.com/download/A/6/C/A6C2FAE9-58A4-410D-81E0-682E8CBF3D18/ServerLanguagePack.exe" #Arabic
	$lang = $xmlinput.Languages.Arabic
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Basque
# Desc: eu-ES
# ===================================================================================
# Region Download Basque
Function Download-Basque([xml]$xmlinput)
{
	$culture = "eu-ES" #Used to rename filename
	$Url = "http://download.microsoft.com/download/0/D/B/0DB91457-43D2-4BCC-A7AF-8559C3E3E1CF/ServerLanguagePack.exe" #Basque
	$lang = $xmlinput.Languages.Basque
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Bulgarian
# Desc: bg-bg
# ===================================================================================
# Region Download Bulgarian
Function Download-Bulgarian([xml]$xmlinput)
{
	$culture = "bg-bg" #Used to rename filename
	$Url = "http://download.microsoft.com/download/9/1/C/91CFFA84-3A8C-4B2B-BD1F-AF77073C832D/ServerLanguagePack.exe" #Bulgarian
	$lang = $xmlinput.Languages.Bulgarian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Catalan
# Desc: ca-es
# ===================================================================================
# Region Download Catalan
Function Download-Catalan([xml]$xmlinput)
{
	$culture = "ca-es" #Used to rename filename
	$Url = "http://download.microsoft.com/download/0/7/B/07B06744-859A-40CF-84BB-4C8113F9FB75/ServerLanguagePack.exe" #Catalan
	$lang = $xmlinput.Languages.Catalan
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-ChineseSimplified
# Desc: zh-Hans
# ===================================================================================
# Region Download ChineseSimplified
Function Download-ChineseSimplified([xml]$xmlinput)
{
	$culture = "zh-Hans" #Used to rename filename
	$Url = "http://download.microsoft.com/download/D/F/C/DFCC90EE-FC55-4EC3-8618-7A2ED0B6F20F/ServerLanguagePack.exe" #Chinese Simplified
	$lang = $xmlinput.Languages.ChineseSimplified
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-ChineseTraditional
# Desc: zh-Hant
# ===================================================================================
# Region Download ChineseTraditional
Function Download-ChineseTraditional([xml]$xmlinput)
{
	$culture = "zh-Hant" #Used to rename filename
	$Url = "http://download.microsoft.com/download/5/D/E/5DE5B04D-DA7E-41DD-8BB5-FE7BF02630B8/ServerLanguagePack.exe" #Chinese Traditional
	$lang = $xmlinput.Languages.ChineseTraditional
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Croatian
# Desc: hr-hr
# ===================================================================================
# Region Download Croatian
Function Download-Croatian([xml]$xmlinput)
{
	$culture = "hr-hr" #Used to rename filename
	$Url = "http://download.microsoft.com/download/B/6/B/B6B2439C-EB60-4361-AB83-71CB6B890ADE/ServerLanguagePack.exe" #Croatian
	$lang = $xmlinput.Languages.Croatian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Czech
# Desc: cs-cz
# ===================================================================================
# Region Download Czech
Function Download-Czech([xml]$xmlinput)
{
	$culture = "cs-cz" #Used to rename filename
	$Url = "http://download.microsoft.com/download/7/B/6/7B67B8FC-81C6-446A-9681-897C0888D592/ServerLanguagePack.exe" #Czech
	$lang = $xmlinput.Languages.Czech
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Danish
# Desc: da-dk
# ===================================================================================
# Region Download Danish
Function Download-Danish([xml]$xmlinput)
{
	$culture = "da-dk" #Used to rename filename
	$Url = "http://download.microsoft.com/download/C/D/7/CD76DD3E-95E4-4504-93CF-F7CD6D8B7CF5/ServerLanguagePack.exe" #Danish
	$lang = $xmlinput.Languages.Danish
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Dutch
# Desc: nl-nl
# ===================================================================================
# Region Download Dutch
Function Download-Dutch([xml]$xmlinput)
{
	$culture = "nl-nl" #Used to rename filename
	$Url = "http://download.microsoft.com/download/D/8/C/D8C7212B-6DFE-439D-B7D6-EFB35D66041E/ServerLanguagePack.exe" #Dutch
	$lang = $xmlinput.Languages.Dutch
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-English
# Desc: en-us
# ===================================================================================
# Region Download English
Function Download-English([xml]$xmlinput)
{
	$culture = "en-us" #Used to rename filename
	$Url = "http://download.microsoft.com/download/1/7/F/17F6BB3B-662F-4555-9760-DB44D3B3F6A4/ServerLanguagePack.exe" #English	
	$lang = $xmlinput.Languages.English
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Estonian
# Desc: et-ee
# ===================================================================================
# Region Download Estonian
Function Download-Estonian([xml]$xmlinput)
{
	$culture = "et-ee" #Used to rename filename
	$Url = "http://download.microsoft.com/download/4/4/6/446DDD4D-DC67-4663-B7C5-CCFA79316703/ServerLanguagePack.exe" #Estonian
	$lang = $xmlinput.Languages.Estonian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Finnish
# Desc: fi-fi
# ===================================================================================
# Region Download Finnish
Function Download-Finnish([xml]$xmlinput)
{
	$culture = "fi-fi" #Used to rename filename
	$Url = "http://download.microsoft.com/download/1/1/6/116C7960-6DFB-468E-BBCB-15E8706783F3/ServerLanguagePack.exe" #Finnish
	$lang = $xmlinput.Languages.Finnish
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-French
# Desc: fr-fr
# ===================================================================================
# Region Download French
Function Download-French([xml]$xmlinput)
{
	$culture = "fr-fr" #Used to rename filename
	$Url = "http://download.microsoft.com/download/8/0/B/80B8DB8F-D863-4DD9-98E0-A3698510EF13/ServerLanguagePack.exe" #French
	$lang = $xmlinput.Languages.French
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Galician
# Desc: gl-es
# ===================================================================================
# Region Download Galician
Function Download-Galician([xml]$xmlinput)
{
	$culture = "gl-es" #Used to rename filename
	$Url = "http://download.microsoft.com/download/D/0/F/D0FE84CB-B591-4D5E-9406-CBA2476D4A94/ServerLanguagePack.exe" #Galician
	$lang = $xmlinput.Languages.Galician
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-German
# Desc: de-de
# ===================================================================================
# Region Download German
Function Download-German([xml]$xmlinput)
{
	$culture = "de-de" #Used to rename filename
	$Url = "http://download.microsoft.com/download/7/3/8/738597D9-2817-46D7-8F70-7FBBEE73ABCF/ServerLanguagePack.exe" #German
	$lang = $xmlinput.Languages.German
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Greek
# Desc: el-gr
# ===================================================================================
# Region Download Greek
Function Download-Greek([xml]$xmlinput)
{
	$culture = "el-gr" #Used to rename filename
	$Url = "http://download.microsoft.com/download/5/F/0/5F03CC80-D10A-43D5-AA1D-E84C6C077E2C/ServerLanguagePack.exe" #Greek
	$lang = $xmlinput.Languages.Greek
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Hebrew
# Desc: he-il
# ===================================================================================
# Region Download Hebrew
Function Download-Hebrew([xml]$xmlinput)
{
	$culture = "he-il" #Used to rename filename
	$Url = "http://download.microsoft.com/download/D/1/0/D10A5EC6-6C6B-4C4B-9FF1-A662B397E850/ServerLanguagePack.exe" #Hebrew
	$lang = $xmlinput.Languages.Hebrew
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Hindi
# Desc: hi-in
# ===================================================================================
# Region Download Hindi
Function Download-Hindi([xml]$xmlinput)
{
	$culture = "hi-in" #Used to rename filename
	$Url = "http://download.microsoft.com/download/7/9/5/795A36AA-D414-4D67-A84D-6815D2FB5A88/ServerLanguagePack.exe" #Hindi
	$lang = $xmlinput.Languages.Hindi
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Hungarian
# Desc: hu-hu
# ===================================================================================
# Region Download Hungarian
Function Download-Hungarian([xml]$xmlinput)
{
	$culture = "hu-hu" #Used to rename filename
	$Url = "http://download.microsoft.com/download/F/D/B/FDB09771-D7FF-4123-A66D-2F0A58687E90/ServerLanguagePack.exe" #Hungarian
	$lang = $xmlinput.Languages.Hungarian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Italian
# Desc: it-it
# ===================================================================================
# Region Download Italian
Function Download-Italian([xml]$xmlinput)
{
	$culture = "it-it" #Used to rename filename
	$Url = "http://download.microsoft.com/download/A/8/4/A843E91B-7AEE-47B4-A144-49F525DEBD9D/ServerLanguagePack.exe" #Italian
	$lang = $xmlinput.Languages.Italian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Japanese
# Desc: ja-jp
# ===================================================================================
# Region Download Japanese
Function Download-Japanese([xml]$xmlinput)
{
	$culture = "ja-jp" #Used to rename filename
	$Url = "http://download.microsoft.com/download/9/4/D/94DDA001-2059-4F02-8810-8662C1098F8D/ServerLanguagePack.exe" #Japanese
	$lang = $xmlinput.Languages.Japanese
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Kazakh
# Desc: kk-kz
# ===================================================================================
# Region Download Kazakh
Function Download-Kazakh([xml]$xmlinput)
{
	$culture = "kk-kz" #Used to rename filename
	$Url = "http://download.microsoft.com/download/F/C/D/FCD57DCD-2BFB-4638-94A3-583AD688CB4D/ServerLanguagePack.exe" #Kazakh
	$lang = $xmlinput.Languages.Kazakh
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Korean
# Desc: ko-kr
# ===================================================================================
# Region Download Korean
Function Download-Korean([xml]$xmlinput)
{
	$culture = "ko-kr" #Used to rename filename
	$Url = "http://download.microsoft.com/download/B/9/D/B9DB186A-8126-49A9-AFA8-C6D63F12AA40/ServerLanguagePack.exe" #Korean
	$lang = $xmlinput.Languages.Korean
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Latvian
# Desc: lv-lv
# ===================================================================================
# Region Download Latvian
Function Download-Latvian([xml]$xmlinput)
{
	$culture = "lv-lv" #Used to rename filename
	$Url = "http://download.microsoft.com/download/3/E/D/3EDD2930-7BEC-4490-B917-7A49CBA7C5E5/ServerLanguagePack.exe" #Latvian
	$lang = $xmlinput.Languages.Latvian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Lithuanian
# Desc: lt-lt
# ===================================================================================
# Region Download Lithuanian
Function Download-Lithuanian([xml]$xmlinput)
{
	$culture = "lt-lt" #Used to rename filename
	$Url = "http://download.microsoft.com/download/E/E/E/EEE0F34F-94D1-4202-B0D0-213C93E20536/ServerLanguagePack.exe" #Lithuanian
	$lang = $xmlinput.Languages.Lithuanian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Norwegian
# Desc: nb-no
# ===================================================================================
# Region Download Norwegian
Function Download-Norwegian([xml]$xmlinput)
{
	$culture = "nb-no" #Used to rename filename
	$Url = "http://download.microsoft.com/download/D/5/9/D596FB84-8ED3-44A4-88D1-FDD4798E226A/ServerLanguagePack.exe" #Norwegian
	$lang = $xmlinput.Languages.Norwegian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Polish
# Desc: pl-pl
# ===================================================================================
# Region Download Polish
Function Download-Polish([xml]$xmlinput)
{
	$culture = "pl-pl" #Used to rename filename
	$Url = "http://download.microsoft.com/download/B/F/1/BF1F45F4-44A8-453D-882D-03BAC1F6A0B5/ServerLanguagePack.exe" #Polish
	$lang = $xmlinput.Languages.Polish
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-PortugeseBrazil
# Desc: pt-br
# ===================================================================================
# Region Download PortugeseBrazil
Function Download-PortugeseBrazil([xml]$xmlinput)
{
	$culture = "pt-br" #Used to rename filename
	$Url = "http://download.microsoft.com/download/6/9/F/69F59A23-C22F-4B22-9D72-790E84F6070E/ServerLanguagePack.exe" #Portugese (Brazil)
	$lang = $xmlinput.Languages.PortugeseBrazil
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Portugese
# Desc: pt-pt
# ===================================================================================
# Region Download Portugese
Function Download-Portugese([xml]$xmlinput)
{
	$culture = "pt-pt" #Used to rename filename
	$Url = "http://download.microsoft.com/download/0/E/F/0EF8F011-89A6-43AE-BD52-090918750432/ServerLanguagePack.exe" #Portugese (Portugal)
	$lang = $xmlinput.Languages.Portugese
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Romanian
# Desc: ro-ro
# ===================================================================================
# Region Download Romanian
Function Download-Romanian([xml]$xmlinput)
{
	$culture = "ro-ro" #Used to rename filename
	$Url = "http://download.microsoft.com/download/8/8/0/880A4C0E-25CA-43B5-84EF-A788FA462AB2/ServerLanguagePack.exe" #Romanian
	$lang = $xmlinput.Languages.Romanian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Russian
# Desc: ru-ru
# ===================================================================================
# Region Download Russian
Function Download-Russian([xml]$xmlinput)
{
	$culture = "ru-ru" #Used to rename filename
	$Url = "http://download.microsoft.com/download/2/6/D/26D339A3-0304-4B66-8062-98BDC0E0D413/ServerLanguagePack.exe" #Russian
	$lang = $xmlinput.Languages.Russian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Serbian
# Desc: sr-Latn-CS 
# ===================================================================================
# Region Download Serbian
Function Download-Serbian([xml]$xmlinput)
{
	$culture = "sr-Latn-cs" #Used to rename filename
	$Url = "http://download.microsoft.com/download/F/D/2/FD2B1BA8-9841-46F9-A4A7-B97294554249/ServerLanguagePack.exe" #Serbian (Latin)
	$lang = $xmlinput.Languages.Serbian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Slovak
# Desc: sk-sk
# ===================================================================================
# Region Download Slovak
Function Download-Slovak([xml]$xmlinput)
{
	$culture = "sk-sk" #Used to rename filename
	$Url = "http://download.microsoft.com/download/0/E/7/0E7A8426-7797-48F9-B396-AA96ADD1D899/ServerLanguagePack.exe" #Slovak
	$lang = $xmlinput.Languages.Slovak
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Slovenian
# Desc: sl-SI
# ===================================================================================
# Region Download Slovenian
Function Download-Slovenian([xml]$xmlinput)
{
	$culture = "sl-SI" #Used to rename filename
	$Url = "http://download.microsoft.com/download/0/3/5/035FD96F-04B1-4461-B8E9-6492654C8549/ServerLanguagePack.exe" #Slovenian
	$lang = $xmlinput.Languages.Slovenian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Spanish
# Desc: es-es
# ===================================================================================
# Region Download Spanish
Function Download-Spanish([xml]$xmlinput)
{
	$culture = "es-es" #Used to rename filename
#	$Url = "http://www.microsoft.com/downloads/" + $culture + "/details.aspx?familyid=" + $guid
	$Url = "http://download.microsoft.com/download/0/D/5/0D547EA0-C094-4D06-BE15-F5111A1D4642/ServerLanguagePack.exe" #Spanish
	$lang = $xmlinput.Languages.Spanish
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Swedish
# Desc: sv-se
# ===================================================================================
# Region Download Swedish
Function Download-Swedish([xml]$xmlinput)
{
	$culture = "sv-se" #Used to rename filename
	$Url = "http://download.microsoft.com/download/5/2/9/5296BCC9-F0ED-461F-9E22-8A816DEC75C8/ServerLanguagePack.exe" #Swedish
	$lang = $xmlinput.Languages.Swedish
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Thai
# Desc: th-th
# ===================================================================================
# Region Download Thai
Function Download-Thai([xml]$xmlinput)
{
	$culture = "th-th" #Used to rename filename
	$Url = "http://download.microsoft.com/download/E/E/A/EEA4DC8B-4979-44C5-AF5E-E326DA04661C/ServerLanguagePack.exe" #Thai
	$lang = $xmlinput.Languages.Thai
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Turkish
# Desc: tr-tr
# ===================================================================================
# Region Download Turkish
Function Download-Turkish([xml]$xmlinput)
{
	$culture = "tr-tr" #Used to rename filename
	$Url = "http://download.microsoft.com/download/2/1/1/2118AF0D-A747-486E-A5BB-6B35E5588247/ServerLanguagePack.exe" #Turkish
	$lang = $xmlinput.Languages.Turkish
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

# ===================================================================================
# Func: Download-Ukranian
# Desc: uk-ua
# ===================================================================================
# Region Download Ukranian
Function Download-Ukranian([xml]$xmlinput)
{
	$culture = "uk-ua" #Used to rename filename
	$Url = "http://download.microsoft.com/download/5/9/D/59DEC052-7E29-4F40-A27A-9AA94A8AAA1A/ServerLanguagePack.exe" #Ukranian
	$lang = $xmlinput.Languages.Ukranian
	If (ShouldIDownload($lang) -eq $true)
	{
		Start-LPDownload $culture
	}
		WriteLine
}
# EndRegion

##### END Functions : Start actual script

## Prompt for the destination path
$DestPath = Read-Host -Prompt "- Enter the destination path for downloaded files"
## Check that the path entered is valid
If (Test-Path "$DestPath" -Verbose)
{
	## If destination path is valid, create folder if it doesn't already exist
	$DestFolder = "$DestPath\LanguagePacks"
	New-Item -ItemType Directory $DestFolder -ErrorAction SilentlyContinue
}
Else
{
	Write-Warning " - Destination path appears to be invalid."
	## Pause
	Write-Host " - Please check the path, and try running the script again."
	Pause
	break
}

# Start Language Downloads
Download-Arabic $xmlinput
Download-Basque $xmlinput
Download-Bulgarian $xmlinput
Download-Catalan $xmlinput
Download-ChineseSimplified $xmlinput
Download-ChineseTraditional $xmlinput
Download-Croatian $xmlinput
Download-Czech $xmlinput
Download-Danish $xmlinput
Download-Dutch $xmlinput
Download-English $xmlinput
Download-Estonian $xmlinput
Download-Finnish $xmlinput
Download-French $xmlinput
Download-Galician $xmlinput
Download-German $xmlinput
Download-Greek $xmlinput
Download-Hebrew $xmlinput
Download-Hindi $xmlinput
Download-Hungarian $xmlinput
Download-Italian $xmlinput
Download-Japanese $xmlinput
Download-Kazakh $xmlinput
Download-Korean $xmlinput
Download-Latvian $xmlinput
Download-Lithuanian $xmlinput
Download-Norwegian $xmlinput
Download-Polish $xmlinput
Download-PortugeseBrazil $xmlinput
Download-Portugese $xmlinput
Download-Romanian $xmlinput
Download-Russian $xmlinput
Download-Serbian $xmlinput
Download-Slovak $xmlinput
Download-Slovenian $xmlinput
Download-Spanish $xmlinput
Download-Swedish $xmlinput
Download-Thai $xmlinput
Download-Turkish $xmlinput
Download-Ukranian $xmlinput

# View the downloaded files in Windows Explorer
Invoke-Item $DestFolder
Pause